/*
 * Copyright (c) 2024. hallele, Inc All rights reserved.
 */

package cn.hallele.ms.demo.domain.action.post;

import cn.hallele.ms.demo.domain.das.PostDDDas;
import cn.hallele.ms.demo.domain.das.PostDEDas;
import cn.hallele.ms.demo.domain.domain.PostDomain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * hallele_ms_demo
 *
 * @author anle5
 * @since 2024/9/15 16:19
 */
@Slf4j
@Service
public class TypicodeDomainService {
    @Autowired
    private PostDDDas postDDDas;

    @Autowired
    private PostDEDas postDEDas;

    // 正式要使用 liteflow 编排流程
    public List<PostDomain> query(int id) {
        PostDomain one = postDEDas.findOne(id);

        List<PostDomain> postDomains = postDDDas.queryPosts();

        postDomains.forEach(postDomain -> {
            postDomain.setId(one.getId());
            postDomain.setText(one.getText());
        });
        log.info("Query successful. Total: {}", postDomains.size());
        return postDomains;
    }

}
